<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> 
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName()+ path+"/" ;
%>
<!DOCTYPE html>
<head>
  <meta charset="utf-8">
  <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![endif]-->
  <title>OAuth2.0 Resources Authentication Platform</title>
  <base href="<%=basePath%>"/>     
  <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" href="css/jquery.bootgrid.css" />  
  <link rel="stylesheet" type="text/css"href="css/bootstrap-dialog.css"/>
  <link rel="stylesheet" type="text/css" href="css/templatemo_main.css" />
  <script src="js/jquery.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
  <script src="js/jquery.bootgrid.js"></script>
  <script src="js/bootstrap-dialog.js"></script>
  <script src="js/jquery.validate.js"></script>
  <script src="js/jquery.form.js"></script>
  <script src="js/messagebox.alert.js"></script>
<!-- 
Dashboard Template 
http://www.templatemo.com/preview/templatemo_415_dashboard
-->
</head>
<body>
	<div class="navbar navbar-inverse" role="navigation">
		<div class="navbar-header">
			<div class="brand">
				<h1>Oauth2.0 Resources Authentication Platform</h1>
			</div>
		</div>
		<div class="navbar-header" style="float:right">
			<div class="info">
				<span>当前用户： <sec:authentication property="name"/></span>
				<a href="<c:url value="/logout" />"><i class="fa fa-sign-out"></i>退出</a>
			</div>
		</div>
	</div>
	<div class="template-page-wrapper">
      <div class="navbar-collapse collapse templatemo-sidebar">
        <ul class="templatemo-sidebar-menu">
          <li style="text-align: center;padding: 10px;">
            <img src="images/logo.png"></img>
          </li>
          <sitemesh:write property='meta.menu'/>
          
          <li class="<sitemesh:write property='meta.profile'/>"><a href="views/profile.jsp"><i class="fa fa-home"></i>概况</a></li>
          <li class="<sitemesh:write property='meta.resources'/>"><a href="views/resources.jsp"><i class="fa fa-archive"></i>资源管理</a></li>
          <li class="<sitemesh:write property='meta.clients'/>"><a href="views/clients.jsp"><i class="fa fa-cubes"></i>应用管理</a></li>
          <li class="<sitemesh:write property='meta.users'/>"><a href="views/users.jsp"><i class="fa fa-users"></i>用户管理</a></li>
          <!--
          <li class="sub open">
            <a href="javascript:;">
              <i class="fa fa-database"></i> Nested Menu <div class="pull-right"><span class="caret"></span></div>
            </a>
            <ul class="templatemo-submenu">
              <li><a href="#">Aenean</a></li>
              <li><a href="#">Pellentesque</a></li>
            </ul>
          </li>
          -->
        </ul>
      </div><!--/.navbar-collapse -->

      <div class="templatemo-content-wrapper">
        <div class="templatemo-content">
          
          <%--@ include file="infos.jsp" --%>
          <sitemesh:write property='body' />
      </div>
      <!-- Modal -->
      <!--
      <div class="modal fade" id="confirmModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
              <h4 class="modal-title" id="myModalLabel">确认退出当前账号？</h4>
            </div>
            <div class="modal-footer">
              <a href="login.jsp" class="btn btn-primary">是</a>
              <button type="button" class="btn btn-default" data-dismiss="modal">否</button>
            </div>
          </div>
        </div>
      </div>
      -->
      <footer class="templatemo-footer">
        <div class="templatemo-copyright">
          <p>Copyright &copy; CD</p>
        </div>
      </footer>
    </div>
    <script type="text/javascript">

	    function createEditDialog(dialogParams,rowData){
	    	 var editDialog = new BootstrapDialog({
		        	type: BootstrapDialog.TYPE_INFO,
		        	title: dialogParams.title,
		        	animate: false,
		        	width:dialogParams.width,
		        	closable: true,
		        	data: {
		                'optionType': dialogParams.optionType
		            },
		        	message: function(dialog) {
		                var msg = $('<div></div>');
		                msg.load(dialogParams.url,function(){
		                	if(rowData){
			                	msg.find('.data-field').each(function(){
			                		if($(this).attr("type")=="checkbox"){
			                			if(rowData[$(this).attr('name')].indexOf($(this).val()) != -1){
			                				$(this).attr("checked","true");
			                			}
			                		}else{
			                			$(this).val(rowData[$(this).attr('name')]);
			                		}
			                	});
			                	msg.find('span.data-field').each(function(){
			                		$(this).html(rowData[$(this).attr('name')]);
			                	});			                	
		                	}
		                	msg.find('.'+dialogParams.optionType+"-remove").remove();
			                dialog.open();
		                });
		                return msg;
		            },
		            buttons: [{
		                label: '取消',
		                action: function(dialog){
		                    dialog.close();
		                }
		            }, {
		                label: '确定',
		                cssClass: 'btn-info',
		                action: function(dialog) {
		                    validateData(dialog,rowData);
		                    dialog.getModalBody().find("form").submit();		                    
		                }
		            }]
		        });
	    	 editDialog.realize();
	    	//layui代码，select的赋值有问题
		        /* var msg = $('<div></div>');
             msg.load('views/editUser.jsp',function(){
             	msg.find("input#id_id").attr('value', rowData.id);
             	msg.find("input#id_username").attr('value', rowData.username);
             	msg.find("input#id_description").attr('value',rowData.description);
             	msg.find("select#id_role").attr('value',rowData.role);
             	layer.open({
 		            type: 1,
 		            title:"编辑用户",
 		            //skin: 'layui-layer-rim', //加上边框
 		            area: ['600px', '440px'], //宽高
 		            content: '<div style="padding:15px;"'+msg.html()+"</div>",
 		            btn: ['确定', '取消'],
 		            btn1: function(index, layero){ //或者使用btn1
 		                //alert('确定');
 		            },
 		            btn2: function(index){ //或者使用btn2
 		            	//alert('取消');
 		            }
 		        });
             }); */
	    };
	    
	    function createDelDialog(dialogParams,rowIds){
	    	var delDialog = BootstrapDialog.confirm({
	        	type: BootstrapDialog.TYPE_DEFAULT,
	        	title: dialogParams.title,
	        	animate: false,
	        	width:dialogParams.width,
	        	closable: true,
	        	btnCancelLabel: '取消',
	            btnOKLabel: '确定',
	            btnOKClass: 'btn-danger',
	            callback: function(result) {
	                // result will be true if button was click, while it will be false if users close the dialog directly.
	                if(result) {
	                    deleteData(rowIds);
	                }else {
	                    //alert('Nope.');
	                }
	            }
	        });
	        delDialog.getModalBody().hide();
	        //layui实现		        
	    	/* layer.confirm("确定删除用户 " + $(this).data("name") +" ?", {icon: 3, title:'提示'}, function(index){
	            //do something
	            alert('aa');
	            layer.close(index);
	        }); */
	    };
    </script>
</body>
</html>